package com.taotao.manager.controller;

import com.taotao.common.pojo.EasyUiDataGridResult;
import com.taotao.common.pojo.TaotaoResult;
import com.taotao.content.service.ContentService;
import com.taotao.manager.pojo.TbContent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class ContentController {
    @Autowired
    private ContentService contentService;
    @RequestMapping("/content/query/list")
    @ResponseBody
    public EasyUiDataGridResult getContentList(@RequestParam(name="page",defaultValue = "1") Integer page,@RequestParam(defaultValue = "30") Integer rows,@RequestParam(defaultValue = "0") Long categoryId) {
        EasyUiDataGridResult result = contentService.getContentList(page, rows, categoryId);
        return result;
    }

    @RequestMapping(value = "/content/save",method = RequestMethod.POST)
    @ResponseBody
    public TaotaoResult saveContent(TbContent content) {
        TaotaoResult result = contentService.saveContent(content);
        return result;
    }

    @RequestMapping(value = "/content/edit",method = RequestMethod.POST)
    @ResponseBody
    public TaotaoResult editContent(TbContent content) {
        TaotaoResult result = contentService.editContent(content);
        return result;
    }

    @RequestMapping(value = "/content/delete",method = RequestMethod.POST)
    @ResponseBody
    public TaotaoResult deleteBatchContent(String ids) {
        TaotaoResult result = contentService.deleteBatchContent(ids);
        return result;
    }

}
